package com.css.zfzx.data.util;

import java.lang.reflect.Field;
import java.util.Collection;
import java.util.Map;

/**
 * @Description: data
 * @Author: lhl
 * @CreateDate: 2021/9/23 17:43
 */

public class PlatformObjectUtils {
    public PlatformObjectUtils() {
    }

    public static boolean isEmpty(Object obj) {
        return obj == null;
    }

    public static boolean isEmpty(Object[] obj) {
        return obj == null || obj.length == 0;
    }

    public static boolean isEmpty(String str) {
        return str == null || "".equals(str) || "null".equalsIgnoreCase(str) || "".equals(str.trim());
    }

    public static boolean isEmpty(Map map) {
        return map == null || map.isEmpty();
    }

    public static boolean isEmpty(Collection collection) {
        return collection == null || collection.isEmpty();
    }

    public static boolean isNotEmpty(Object obj) {
        return !isEmpty(obj);
    }

    public static boolean isNotEmpty(Object[] obj) {
        return !isEmpty(obj);
    }

    public static boolean isNotEmpty(String str) {
        return !isEmpty(str);
    }

    public static boolean isNotEmpty(Map map) {
        return !isEmpty(map);
    }

    public static boolean isNotEmpty(Collection collection) {
        return !isEmpty(collection);
    }

    public static boolean checkFieldAllNull(Object object) throws IllegalAccessException {
        Field[] var1 = object.getClass().getDeclaredFields();
        int var2 = var1.length;

        int var3;
        Field f;
        for(var3 = 0; var3 < var2; ++var3) {
            f = var1[var3];
            f.setAccessible(true);
            if (!isEmpty(f.get(object))) {
                return false;
            }

            f.setAccessible(false);
        }

        var1 = object.getClass().getFields();
        var2 = var1.length;

        for(var3 = 0; var3 < var2; ++var3) {
            f = var1[var3];
            f.setAccessible(true);
            if (!isEmpty(f.get(object))) {
                return false;
            }

            f.setAccessible(false);
        }

        return true;
    }
}

